package org.kunlong.qgen.parser;

import org.dom4j.Element;
import org.kunlong.qgen.domain.QuestionType;

public abstract class AbstractParser implements Parser {
	private QuestionType questionType;

	protected String getDescription(Element e) {
		return returnSimpleText(e, "Description");
	}

	private String returnSimpleText(Element e, String tagName) {
		Element tag = e.element(tagName);
		if (tag == null) {
			return null;
		} else {
			return tag.getText().trim();
		}
	}

	protected String getAnswer(Element e) {
		return returnSimpleText(e, "Answer");
	}

	public QuestionType getQuestionType() {
		// TODO Auto-generated method stub
		return questionType;
	}

	public void setQuestionType(QuestionType questionType) {
		// TODO Auto-generated method stub
		this.questionType = questionType;
	}
}
